﻿using System;
using System.Collections.Generic;
using System.Linq;
using Wicresoft.SMS.Data;
using System.Text;
using Wicresoft.SMS.Common;

namespace Wicresoft.SMS.Gateway.Host
{
    public abstract class Task
    {
        protected System.Threading.Thread _thread;
        protected bool _scanAble;

        public Task()
        {
            _thread = new System.Threading.Thread(new System.Threading.ThreadStart(ExecuteCore));
        }
        public void Execute()
        {
            //DBLog.Dubug(string.Format("Enter Task." + _thread.ToString()));
            if (_thread.ThreadState == System.Threading.ThreadState.Unstarted)
            {
                _scanAble = true;
                _thread.Start();
            }
            //if (_thread.ThreadState == System.Threading.ThreadState.Running)
            //    DBLog.Dubug(string.Format("Running Task." + _thread.ToString()));
        }
        public void AbortScan()
        {
            _scanAble = false;
            _thread.Abort();
        }
        protected virtual int TaskEnable { get; set; }
        protected virtual int TaskSpan { get; set; }
        protected abstract void ExecuteCore();
    }
}
